package com.ruoyi.zhike.controller.sms;

import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.zhike.db.domain.SmsRecordInfo;
import com.ruoyi.zhike.system.service.ISmsRecordInfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.zhike.wrapper.SmsRecordInfoWrapper;

/**
 * 短信发送记录Controller
 * 
 * @author ruoyi
 * @date 2024-04-17
 */
@RestController
@RequestMapping("/sms/recordInfo")
public class SmsRecordInfoController extends BaseController
{
    @Autowired
    private ISmsRecordInfoService smsRecordInfoService;

    /**
     * 查询短信发送记录列表
     */
    @RequiresPermissions("sms:recordInfo:list")
    @GetMapping("/list")
    public TableDataInfo list(SmsRecordInfo smsRecordInfo)
    {
        startPage();
        List<Map<String, Object>> list = smsRecordInfoService.selectSmsRecordInfoListMap(smsRecordInfo);
        list = new SmsRecordInfoWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出短信发送记录列表
     */
    @RequiresPermissions("sms:recordInfo:export")
    @Log(title = "短信发送记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SmsRecordInfo smsRecordInfo)
    {
        List<SmsRecordInfo> list = smsRecordInfoService.selectSmsRecordInfoList(smsRecordInfo);
        ExcelUtil<SmsRecordInfo> util = new ExcelUtil<SmsRecordInfo>(SmsRecordInfo.class);
        util.exportExcel(response, list, "短信发送记录数据");
    }

    /**
     * 获取短信发送记录详细信息
     */
    @RequiresPermissions("sms:recordInfo:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(smsRecordInfoService.selectSmsRecordInfoById(id));
    }

    /**
     * 新增短信发送记录
     */
    @RequiresPermissions("sms:recordInfo:add")
    @Log(title = "短信发送记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SmsRecordInfo smsRecordInfo)
    {
        return toAjax(smsRecordInfoService.insertSmsRecordInfo(smsRecordInfo));
    }

    /**
     * 修改短信发送记录
     */
    @RequiresPermissions("sms:recordInfo:edit")
    @Log(title = "短信发送记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SmsRecordInfo smsRecordInfo)
    {
        return toAjax(smsRecordInfoService.updateSmsRecordInfo(smsRecordInfo));
    }

    /**
     * 删除短信发送记录
     */
    @RequiresPermissions("sms:recordInfo:remove")
    @Log(title = "短信发送记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(smsRecordInfoService.deleteSmsRecordInfoByIds(ids));
    }
}
